﻿using System.IO;
using System.Xml.Serialization;

namespace TFSTeamCityNotify
{
    public static class Serializer
    {
        public static string Serialize<T>(T obj)
        {
            var emptyNameSpace = new XmlSerializerNamespaces();
            emptyNameSpace.Add("", "");

            var s = new XmlSerializer(typeof(T));
            var sw = new StringWriter();
            s.Serialize(sw, obj, emptyNameSpace);
            return sw.ToString();
        }

        public static T Deserialize<T>(string xml)
        {
            var s = new XmlSerializer(typeof(T));
            var sr = new StringReader(xml);
            return (T)s.Deserialize(sr);
        }
    }
}